<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .div1 {
            width: 300px;
            height: 300px;
            background-color: pink;
        }
        .div2 {
            width: 200px;
            height: 200px;
            background-color: purple;
        }
        .div3 {
            width: 100px;
            height: 100px;
            background-color: aqua;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- v-once 单次插值，只会在初次渲染时显示变量，后续数据修改时不再更新 -->
        <p v-once>{{msg}}</p>
        <p>{{msg}}</p>
        <hr>
        <!-- v-pre:显示源代码，而不是计算结果 -->
        <p v-pre>{{msg}}</p>
        <hr>
        <p>修饰符：实现一些小功能。分类：事件修饰符、按键修饰符、鼠标修饰符、系统修饰符、表单修饰符</p>
        <!-- .stop 阻止冒泡 -->
        <div class="div1" @click="show('div1')">
            <div class="div2" @click.stop="show('div2')">
                <div class="div3" @click="show('div3')"></div>
            </div>
        </div>
        <hr>
        <!-- .prevent 阻止默认事件 -->
        <div class="div3" @contextmenu.prevent="right"></div>
        <hr>
        <!-- .self 只有自己才能触发事件的执行 -->
        <div class="div1" @click.self="show('div1')">
            <div class="div2" @click="show('div2')">
                <div class="div3" @click="show('div3')"></div>
            </div>
        </div>
        <hr>
        <!-- .once 只执行一次 -->
        <button @click.once="buy">秒杀</button>
        <hr>
        <!-- .capture 按照捕获的方式执行，或者说是 优先执行 -->
        <div class="div1" @click.capture="show('div1')">
            <div class="div2" @click.capture="show('div2')">
                <div class="div3" @click.capture="show('div3')"></div>
            </div>
        </div>
    </div>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                msg: '中午吃什么？'
            },
            methods: {
                show(name) {
                    console.log('我是',name);
                },
                right() {
                    console.log('right了。。。');
                },
                buy() {
                    console.log('偶买噶，买它');
                }
            }
        })
    </script>
</body>
</html>